<script setup>

import {nextTick, onMounted} from "vue";
import * as echarts from "echarts";

onMounted(async () => {
  await left1Chart()
})

const left1Chart = async () => {
  await nextTick()
  setTimeout(() => {
    const myChart = echarts.init(document.getElementById('left1'))
    const option = {
      tooltip: {
        trigger: 'axis',
        axisPointer: {
          type: 'shadow'
        }
      },
      legend: {
        show: true,
        right: 0,
        icon: 'rect',
        textStyle: {
          color: '#8d98a2',
          fontSize: 12,
          fontWeight: 'bold',
        },
      },
      grid: {
        top: '10%',
        left: '0%',
        right: '4%',
        bottom: '3%',
        containLabel: true
      },
      xAxis: {
        type: 'category',
        data: ['流量1', '流量2', '流量3', '流量4', '流量5', '流量6', '流量7', '流量8', '流量9', '流量10'],
        axisLabel: {
          color: '#8d98a2',
          fontSize: 12,
          fontWeight: 'bold',
        },
      },
      yAxis: {
        type: 'value',
        axisLine: {
          show: false,
        },
        axisTick: {
          show: false,
        },
        splitLine: {
          show: false,
        },
        axisLabel: {
          color: '#fff',
          fontSize: 12,
          fontWeight: 'bold',
          formatter: function (value) {
            return value / 1000 + 'k'
          }
        }
      },
      series: [
        {
          name: '2023年',
          type: 'bar',
          data: [18203, 23489, 29034, 104970, 131744, 630230, 131744, 630230, 131744, 630230],
          barWidth: 10,
          itemStyle: {
            normal: {
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                offset: 0,
                color: 'rgba(0,244,255,1)' // 0% 处的颜色
              }, {
                offset: 1,
                color: 'rgba(0,77,167,1)' // 100% 处的颜色
              }], false),
              barBorderRadius: [30, 30, 30, 30],
              shadowColor: 'rgba(0,160,221,1)',
              shadowBlur: 4,
            }
          },
          "showBackground": true,
          backgroundStyle: {
            color: "#12222e"
          },
        }
      ]
    }
    myChart.setOption(option)
  }, 500)
}
</script>

<template>
  <div id="left1"></div>
</template>

<style scoped lang="scss">
#left1{
  width: 457px;
  height: 293px;
}
</style>
